import {get, post, del, put} from '@/utils/request'

// 产品类型相关
export const getProductTypes = (params) => {
  return get('/product/product-client/api/productCategory/list?'+ new URLSearchParams(params).toString())
}

export const fetchTypesByName = (params) => {
  return get('/product/product-client/api/productInfo/searchByCategoryName?'+ new URLSearchParams(params).toString())
}

export const saveProductType = (data) => {
  return post('/product/product-client/api/productCategory/add', data)
}

export const updateProductType = (id,data) => {
  return put(`/product/product-client/api/productCategory/update/${id}`, data)
}

export const deleteProductType = (id) => {
  return del(`/product/product-client/api/productCategory/del/${id}`)
}

// 产品相关
export const getProducts = (params) => {
  return get('/product/product-client/api/productInfo/list?'+ new URLSearchParams(params).toString())
}

export const addProduct = (data) => {
  return post('/product/product-client/api/productInfo/add', data)
}

export const updateProduct = (id, data) => {
  return put(`/product/product-client/api/productInfo/update/${id}`, data)
}

export const deleteProduct = (id) => {
  return del(`/product/product-client/api/productInfo/delete/${id}`)
}
export const getProductDetail = (id) => {
  return get(`/product/product-client/api/productInfo/get/${id}`)
}
export const searchProductsByName = (params) => {
  return get('/product/product-client/api/productInfo/searchByName?' + new URLSearchParams(params).toString())
}
export const searchProductsByCategoryName = (params) => {
  return get('/product/product-client/api/productInfo/searchByCategoryName?' + new URLSearchParams(params).toString())
}
